package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.vo.SysAssetDisposalVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysAssetDisposal;
import com.ruoyi.system.service.ISysAssetDisposalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 资产处置Controller
 * 
 * @author sxy
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/disposal")
public class SysAssetDisposalController extends BaseController
{
    @Autowired
    private ISysAssetDisposalService sysAssetDisposalService;

    /**
     * 查询资产处置列表
     */
    @RequiresPermissions("system:disposal:list")
    @GetMapping("/list")
    public TableDataInfo list(SysAssetDisposal sysAssetDisposal)
    {
        startPage();
        List<SysAssetDisposalVo> list = sysAssetDisposalService.selectSysAssetDisposalList(sysAssetDisposal);
        return getDataTable(list);
    }

    /**
     * 导出资产处置列表
     */
    @RequiresPermissions("system:disposal:export")
    @Log(title = "资产处置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysAssetDisposal sysAssetDisposal)
    {
        List<SysAssetDisposalVo> list = sysAssetDisposalService.selectSysAssetDisposalList(sysAssetDisposal);
        ExcelUtil<SysAssetDisposalVo> util = new ExcelUtil<SysAssetDisposalVo>(SysAssetDisposalVo.class);
        util.exportExcel(response, list, "资产处置数据");
    }

    /**
     * 获取资产处置详细信息
     */
    @RequiresPermissions("system:disposal:query")
    @GetMapping(value = "/{disposalId}")
    public AjaxResult getInfo(@PathVariable("disposalId") Long disposalId)
    {
        return success(sysAssetDisposalService.selectSysAssetDisposalByDisposalId(disposalId));
    }

    /**
     * 新增资产处置
     */
    @RequiresPermissions("system:disposal:add")
    @Log(title = "资产处置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysAssetDisposal sysAssetDisposal)
    {
        return toAjax(sysAssetDisposalService.insertSysAssetDisposal(sysAssetDisposal));
    }

    /**
     * 修改资产处置
     */
    @RequiresPermissions("system:disposal:edit")
    @Log(title = "资产处置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysAssetDisposal sysAssetDisposal)
    {
        return toAjax(sysAssetDisposalService.updateSysAssetDisposal(sysAssetDisposal));
    }

    /**
     * 删除资产处置
     */
    @RequiresPermissions("system:disposal:remove")
    @Log(title = "资产处置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{disposalIds}")
    public AjaxResult remove(@PathVariable Long[] disposalIds)
    {
        return toAjax(sysAssetDisposalService.deleteSysAssetDisposalByDisposalIds(disposalIds));
    }
}
